<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
  <input type="text" v-model="emp.name" placeholder="姓名">
  <input type="text" v-model="emp.salary" placeholder="工资">
  <input type="text" v-model="emp.job" placeholder="工作">
  <input type="button" value="添加" @click="add()">
  <table border="1">
    <caption>员工列表</caption>
    <tr>
      <th>编号</th>
      <th>姓名</th>
      <th>工资</th>
      <th>工作</th>
      <th>操作</th>
    </tr>
    <tr v-for="(emp,i) in arr">
      <td>{{i+1}}</td> <!--i为数组元素的下标-->
      <td>{{emp.name}}</td>
      <td>{{emp.salary}}</td>
      <td>{{emp.job}}</td>
      <td><input type="button" value="删除" @click="del()"></td>
    </tr>

  </table>
  <script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
  <script>
      let v = new Vue({
          el:"body>div",
          data: {
            emp: {name: "", salary: "", job: ""},//emp是个对象,类似于{}
            arr: [{name: "小谭", salary: "4500", job: "销售"},
                  {name: "小张", salary: "3000", job: "人事"},
                  {name: "小吴", salary: "5000", job: "程序员"}]
          },
          methods:{
             add(){
               v.arr.push({name:v.emp.name,salary:v.emp.salary,job:v.emp.job})
             },
            del(i){ // 删除位置,删除数量
               v.arr.splice(i,1);
            }
          }
      })
  </script>
</div>
</body>
</html>